home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok59.lha
/
AmokEd_V1.02b
/
txt
/
EdSecureDos.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
3KB
|
171 lines
(*-------------------------------------------------------------------------*)
(* *)
(* Amiga Oberon Library Module: SecureDos Date: 13 Sep 1991 22:54:04
Adapted for AmokEd!!
*)
(* © 1990 by Fridtjof Siebert *)
(* *)
(*-------------------------------------------------------------------------*)
(* modified for AmokEd 24 May 1991 [hG] *)
MODULE EdSecureDos;
IMPORT d*: Dos,
e: Exec,
l: EdLists, (* the only change, but makes AmokEd smaller *)
ol: OberonLib,
s:SYSTEM;
VAR
Me * : d.ProcessPtr;
TYPE
FHNodePtr = POINTER TO FHNode;
FHNode = STRUCT (node: l.Node)
fh: d.FileHandlePtr
END;
LockNodePtr = POINTER TO LockNode;
LockNode = STRUCT (node: l.Node)
lock: d.FileLockPtr
END;
VAR
fhlist: l.List;
locklist: l.List;
oldCurrentDir*: d.FileLockPtr;
Sigs: LONGSET;
PROCEDURE Open*(name: ARRAY OF CHAR; (* $CopyArrays- *)
accessMode: LONGINT): d.FileHandlePtr;
VAR
el: FHNodePtr;
BEGIN
NEW(el);
IF el=NIL THEN RETURN NIL END;
el.fh := d.Open(name,accessMode);
IF el.fh=NIL THEN
DISPOSE(el);
RETURN NIL
END;
l.AddHead(fhlist,el);
RETURN el.fh;
END Open;
PROCEDURE Close*(file: d.FileHandlePtr);
VAR el: l.NodePtr;
BEGIN
el := l.Head(fhlist);
REPEAT
IF el(FHNode).fh=file THEN
l.Remove(fhlist,el);
d.OldClose(file);
DISPOSE(el);
RETURN;
END;
UNTIL NOT l.Next(el);
HALT(20); (* File gar nicht offen! *)
END Close;
PROCEDURE Lock*(name: ARRAY OF CHAR; (* $CopyArrays- *)
accessMode: LONGINT): d.FileLockPtr;
VAR el: LockNodePtr;
BEGIN
NEW(el);
IF el=NIL THEN RETURN NIL END;
el.lock := d.Lock(name,accessMode);
IF el.lock=NIL THEN DISPOSE(el); RETURN NIL END;
l.AddHead(locklist,el);
RETURN el.lock;
END Lock;
PROCEDURE AddLock(lock: d.FileLockPtr): d.FileLockPtr;
VAR el: LockNodePtr;
BEGIN
IF lock#NIL THEN
NEW(el);
IF el#NIL THEN
el.lock := lock;
l.AddHead(locklist,el);
RETURN lock;
END;
d.UnLock(lock);
END;
RETURN NIL;
END AddLock;
PROCEDURE ParentDir*(lock: d.FileLockPtr): d.FileLockPtr;
BEGIN
RETURN AddLock(d.ParentDir(lock));
END ParentDir;
PROCEDURE DupLock*(lock: d.FileLockPtr): d.FileLockPtr;
BEGIN
RETURN AddLock(d.DupLock(lock));
END DupLock;
PROCEDURE CreateDir*(name: ARRAY OF CHAR): d.FileLockPtr; (* $CopyArrays- *)
BEGIN
RETURN AddLock(d.CreateDir(name));
END CreateDir;
PROCEDURE UnLock*(lock: d.FileLockPtr);
VAR el: l.NodePtr;
BEGIN
el := l.Head(locklist);
REPEAT
IF el(LockNode).lock=lock THEN
l.Remove(locklist,el);
d.UnLock(lock);
DISPOSE(el);
RETURN;
END;
UNTIL NOT l.Next(el);
HALT(20); (* existiert nicht ! *)
END UnLock;
PROCEDURE * CloseIt(n: l.NodePtr);
BEGIN
d.OldClose(n(FHNode).fh)
END CloseIt;
PROCEDURE * UnLockIt(n: l.NodePtr);
BEGIN
d.UnLock(n(LockNode).lock);
END UnLockIt;
BEGIN
Me := s.VAL(d.ProcessPtr,ol.Me);
oldCurrentDir := Me.currentDir;
l.Init(fhlist);
l.Init(locklist);
CLOSE
IF d.CurrentDir(oldCurrentDir)=NIL THEN END;
l.DoForward(fhlist,CloseIt);
l.DoForward(locklist,UnLockIt);
END EdSecureDos.